export default class Dom {
    constructor(tag: string, id: string = Dom.randomName(), wh: { width: number | string, height: number | string } = { width: 200, height: 200 }) {
        const Node = document.createElement(tag);
        Node.id = id;
        Node.style.width = `${typeof wh.width === "number" ? `${wh.width}px` : wh.width}`;
        Node.style.height = `${typeof wh.height === "number" ? `${wh.height}px` : wh.height}`;
        return Node;
    }
    static getNode(id: string): HTMLElement | null {
        const node: HTMLElement = document.getElementById(id) as HTMLElement;
        if (node !== null) {
            return node;
        } else {
            console.info(`在body中没找到id为：${id}的元素`);
        }
        return null;
    }
    static randomName(): string {
        const name: string = Math.random().toString(36).slice(2);
        return name;
    }
}